Implement time shift support in expression evaluation#190
Closed
Implement time shift support in expression evaluation#190
Conversation
Variable bounds containing TimeShiftNode were raising NotImplementedError when evaluated. Added shift() to ValueProvider so the evaluator can evaluate shifted sub-expressions at the correct timestep (t + offset). https://claude.ai/code/session_011kQZpMxUpTSdBHFe3F7unJ
Adds eval_at(timestep) and all_block_timesteps() to ValueProvider so the evaluator can handle absolute timestep evaluation (time_eval) and aggregation over all timesteps (all_time_sum). time_sum reuses the existing shift() to sum the operand over a relative shift range. https://claude.ai/code/session_011kQZpMxUpTSdBHFe3F7unJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for time shifting in expression evaluation by introducing a
shift()method to theValueProviderinterface and implementing time shift evaluation in the expression visitor.Key Changes
shift(offset: int)method toValueProviderinterface to enable temporal offset operationstime_shift()method inEvaluationVisitorto evaluate time-shifted expressions by computing the shift offset and creating a new evaluation context with the shifted timestepshift()implementations to allValueProviderimplementations:EvaluationContext: Returns self (no-op for base context)_make_value_providerin optimization.py: Creates new provider with adjusted timestepExtraOutputValueProvider: Returns self (no-op)shift()methodImplementation Details
The time shift evaluation works by:
EvaluationVisitorwith a shifted context (viacontext.shift(offset))This allows expressions to reference values at different timesteps during evaluation.
https://claude.ai/code/session_011kQZpMxUpTSdBHFe3F7unJ